package com.air.repo.design.pattern.factory;

/**
 * Place Function on Here:
 *
 * @author yh 2018/7/11 22:52
 * @since: Jdk 1.8
 */
public class SimpleFactory {

    public Person getPerson(String name){
        if("man".equals(name)){
            return new Man();
        }else{
            return new Girl();
        }
    }



    public static<T>  T createObj(Class clz){
        T o=null;
        try {
             o = (T)Class.forName(clz.getName()).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return o;
    }


    public static void main(String[] args) {
//        Person person = new SimpleFactory().getPerson("aa");
//        person.request();



        new ManFactory().getPerson().request();

    }
}
